﻿using UnityEngine;
using System.Collections;

public class ResourcesLoadHepler 
{
    /// <summary>
    /// 读取战斗场景里面，要加载的游戏GameObject对象
    /// </summary>
    /// <param name="enemyPrefabName">敌人Prefab文件名称</param>
    /// <returns></returns>
    public static GameObject LoadEnemy(string  enemyPrefabName)
    {

        if (enemyPrefabName.Trim() == "" || enemyPrefabName == null)
        {
            Debug.LogError("LoadEnemy is  null,传入的enemyPrefab参数有错误");
            return null;
        }
        else
        {
            GameObject e = Resources.Load("EnemyPrefab/" + enemyPrefabName, typeof(GameObject)) as GameObject;
            Debug.Log("LoadEnemy读取到的游戏对象名称是：" + e.gameObject);
            if (e == null)
            {
                Debug.LogError("LoadEnemy is  null,尝试从EnemyPrefab加载战斗敌人对象失败");
            }
            return e;
        }

    }

    public static GameObject LoadPersonFireObject(string peronPrefabName)
    {

        if (peronPrefabName.Trim() == "" || peronPrefabName == null)
        {
            Debug.LogError("LoadPersonFireObject is  null,peronPrefabName");
            return null;
        }
        else
        {
            GameObject e = Resources.Load("PersonFirePrefab/" + peronPrefabName, typeof(GameObject)) as GameObject;
            Debug.Log("LoadPersonFireObject读取到的游戏对象名称是：" + e.gameObject);
            if (e == null)
            {
                Debug.LogError("LoadPersonFireObject is  null,尝试从PersonFirePrefab加载角色子弹对象失败");
            }
            return e;
        }

    }


}
